import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Antd from 'ant-design-vue';
import {registerApplication,start} from 'single-spa'
Vue.config.productionTip = false
import 'ant-design-vue/dist/antd.css';

Vue.use(Antd);

function loadScript(url){
  return new Promise((resolve,reject)=>{
    let script = document.createElement('script')
    script.src = url
    script.onload = resolve
    script.onerror = reject
    document.head.append(script)
  })
  
}
//注册应用
registerApplication('ldxParentVue',
   async ()=>{
     await loadScript('http://localhost:10000/js/chunk-vendors.js')
     await loadScript('http://localhost:10000/js/app.js')
     console.log('加载',window);
     return window.singleVue
   },
   location=>location.pathname.startsWith('/vue'),
 )
 //启动
 start()

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
